<header class="auth-setting-header">
    <h1>品牌管理</h1>
</header>
<div class="tools-row clearfix">

</div>

<div class="tools-row clearfix">
<div class="col-xs-4">
        <a class="btn btn-success" data-ng-click="brandCtrl.addBrand()">添加</a>
        <a class="btn btn-danger" data-ng-show="brandCtrl.toggleCheckbox||brandCtrl.showOperationButton" data-ng-click="brandCtrl.deleteAll()">删除</a>
</div>
<div class="col-xs-8">
    <form class="form-inline pull-right">
<!--         <div class="form-group">

            <input type="text" class="form-control" data-ng-model='brandFilter' placeholder="产品号/型号">
            <a data-ng-click="brandCtrl.resetFilter()" class="ml-sm btn btn-warning pull-right">清楚筛选条件</a>

            </div> -->
    </form>
</div>
</div>

<div class="table-padding">

        <table class="table table-bordered">
            <tr>
              <td data-ng-click="brandCtrl.toggleAllCheckbox()"><checkbox  ng-model="brandCtrl.toggleCheckbox" ></checkbox></td>
              <td>品牌名称</td>
              <td>简介</td>
              <td>拼音首字母</td>
              <td>行业</td>
              <td>产地</td>
              <td>厂家</td>
              <td>联系电话</td>
              <td>操作</td>
            </tr>
            <tr ng-repeat="brand in brandCtrl.brands">
              <td data-ng-click="brandCtrl.showOperation(brand.$selected)">
                  <checkbox ng-model="brand.$selected"></checkbox> 
              </td>
              <td>
                <span editable-text="brand.name" e-name="name" e-form="rowform" onbeforesave='brandCtrl.checkData($data)' e-required=''>
                  {{ brand.name || '暂无' }}
                </span>
              </td>
              <td>
                <span editable-text="brand.description" e-name="description" e-form="rowform" onbeforesave='brandCtrl.checkData($data,brand)' e-required=''>
                  {{ brand.description || '暂无' }}
                </span>
              </td>
              <td>
                <span editable-select="brand.first_letter" e-name="first_letter"  e-ng-options='g as g for g in brandCtrl.initials'  e-form="rowform" onbeforesave='brandCtrl.checkData($data)'>
                  {{ brand.first_letter || '暂无' }}
                </span>
              </td>
              <td>
                <span>
                  <span data-ng-class="{'btn btn-xs btn-success':rowform.$visible,'btn btn-xs btn-primary':brandCtrl.insertedata==brand}" data-ng-click="brandCtrl.selectField(brand,rowform.$visible)">{{ brandCtrl.showFieldName(brand) }}</span>
                </span>
              </td>
              <td>
                <span editable-text="brand.country" e-name="country" e-form="rowform" onbeforesave='brandCtrl.checkData($data)' e-required=''>
                  {{ brand.country || '暂无' }}
                </span>
              </td>
              <td>
                <span editable-text="brand.factory_name" e-name="factory_name" e-form="rowform" onbeforesave='brandCtrl.checkData($data)' e-required=''>
                  {{ brand.factory_name || '暂无' }}
                </span>
              </td>
              <td>
                <span editable-text="brand.contact" e-name="contact" e-form="rowform" onbeforesave='brandCtrl.checkData($data)' e-required=''>
                  {{ brand.contact || '暂无' }}
                </span>
              </td>
              <td style="white-space: nowrap">
                <form editable-form name="rowform"  shown="brandCtrl.insertedata == brand" onbeforesave='brandCtrl.saveBrand($data,brand.id,brand.field_id)' ng-show="rowform.$visible" class="form-buttons form-inline">
                  <button type="submit" ng-disabled="rowform.$waiting" class="btn btn-info">
                    保存
                  </button>
                  <a ng-disabled="rowform.$waiting" ng-click="brandCtrl.cancel(rowform,brand)" class="btn btn-default">
                    取消
                  </a>
                </form>
                <div class="buttons" ng-show="!rowform.$visible">
                  <a class="btn btn-info" ng-click="rowform.$show()"><em class="icon-pencil"></em></a>
                  <a class="btn btn-danger" ng-click="brandCtrl.removeBrand(brand,$index)"><em class="icon-trash"></em></a>
                </div>  
              </td>
            </tr>
          </table>
          <p class="text-center" data-ng-show="brandCtrl.brands.length<1">暂无内容</p>
          <uib-pagination ng-if='brandCtrl.pagination.total_item' ng-change="brandCtrl.paginationChange()" total-items="brandCtrl.pagination.total_item" items-per-page="brandCtrl.pagination.page_size" ng-model="brandCtrl.pagination.page_no" max-size="brandCtrl.pagination.max_size"  class="pagination-sm" boundary-link-numbers="true" rotate="false" next-text="下一页" previous-text="上一页"></uib-pagination>
</div>